package com.spzx.order.api.factory;

import com.spzx.common.core.domain.R;
import com.spzx.order.api.RemoteGetByOrderNo;
import com.spzx.order.api.domain.OrderInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * ClassName: RemoteOrderInfoFallbackFactory
 * Description:
 *
 * @Author linz
 * @Creat 2025/3/25 19:03
 * @Version 1.00
 */
@Slf4j
public class RemoteOrderInfoFallbackFactory implements FallbackFactory<RemoteGetByOrderNo> {
    @Override
    public RemoteGetByOrderNo create(Throwable cause) {
        log.error("订单服务调用失败：{}", cause.getMessage());
        return new RemoteGetByOrderNo() {
            @Override
            public R<OrderInfo> getByOrderNo(String orderNo, String source) {
                cause.printStackTrace();
                return R.fail("根据订单号获取订单信息失败->"+cause.getMessage());
            }
        };
    }
}
